package jinyilw.swing.rlaf.ui;

import javax.swing.JComponent;
import javax.swing.JInternalFrame;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.RootPaneUI;
import javax.swing.plaf.basic.BasicInternalFrameUI;

/**
 * @author Jinyi
 */
public class RInternalFrameUI extends BasicInternalFrameUI
{

	public static ComponentUI createUI(JComponent b)
	{
		return new RInternalFrameUI((JInternalFrame) b);
	}

	public RInternalFrameUI(JInternalFrame b)
	{
		super(b);
	}

	@Override
	public void installUI(JComponent c)
	{
		frame = (JInternalFrame) c;
		installDefaults();
		installListeners();
		installComponents();
		installKeyboardActions();

		RootPaneUI ui = frame.getRootPane().getUI();
		if (ui instanceof RRootPaneUI)
		{
			RRootPaneUI rUi = (RRootPaneUI) ui;
			// rUi.setDecorationStyle(RRootPaneUI.INTERNAL_FRAME);
			rUi.setOptionStyle(100, 0.95f);
		}
		frame.setBorder(new RInternalFrameBorder());
	}

	@Override
	protected JComponent createNorthPane(JInternalFrame w)
	{
		titlePane = new RInternalFrameTitlePane(w);
		return titlePane;
	}
}
